Page({
  data: {
    weatherData: {},
    city: '',
    lifeData:{},
    searchPanelShow: false
  },
  getWeatherDate: function (city) {
    var that = this
    wx.request({
      url: "https://api.map.baidu.com/telematics/v3/weather",
      data: {
        ak: '0A5bc3c4fb543c8f9bc54b77bc155724',
        output: 'json',
        location: city || '广州'
      },
      success: function (res) {
        wx.hideLoading(),
        that.setData({
          weatherData: res.data.results[0].weather_data,
          lifeData : res.data.results[0].index,
        });
      },
      fail: function (error) {
        
      }
    })
  },
  onBindBlur: function (event) {
    this.getWeatherDate(event.detail.value);
  },
  onBindFocus: function (event) {
    if (event.detail.value){
      this.setData({
        searchPanelShow: true
      })
    }
    
  },
  onCancelImgTap: function (event) {
    this.setData({
      searchPanelShow: false,
      city:''
    }
    )
  },
  onLoad: function () {
    wx.showLoading({
      title: '加载中',
      mask: true
    })
    this.getWeatherDate("广州");
   
  }
})